﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MiniChat;

namespace MiniChat
{
    public class MyDb: DataContext
    {
        public MyDb():base(@"isostore:/database.sdf")
        {            
        }
        public bool GetCache(string username, string cacheurl)
        {
            var u = Tblcaches.Where(p=>p.UserName == username)
                .FirstOrDefault();
            if (u == null)
            {
                Tblcaches.InsertOnSubmit(new Tblcache() { Imagelink = cacheurl, UserName = username });
                base.SubmitChanges();
                return false;
            }
            else {
                if (u.Imagelink == cacheurl)
                {
                    return true;
                }
                else {
                    u.Imagelink = cacheurl;
                    base.SubmitChanges();
                    return false;
                }
            }
        }
    }
}
